﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CompanySearchConsole;
using MongoDB.Driver;

namespace ElasticSearch.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanySync syncronizer = new CompanySync();
           // syncronizer.ImportAll();

            if (args == null || args.Length < 1)
            {
                Console.WriteLine("number of participants expected");
                return;
            }
            int pNo = 0;
            if (!int.TryParse(args[0], out pNo) || pNo < 1)
            {
                Console.WriteLine("number of participants expected > 0");
                return;
            }

            var mongoDb = GetMongoDatabase();
            TestSuite tests = new TestSuite(mongoDb, new CompanySync());
            tests.repeatNo = 10;
            tests.ExecuteTests(pNo);

            Console.Read();

        }


        private static MongoDatabase GetMongoDatabase()
        {

            string connectionString = "mongodb://localhost:27017/ESResults";
            var dbConnectionString = MongoUrl.Create(connectionString);

            var client = new MongoClient(dbConnectionString);
            var server = client.GetServer();
            var clientMongoDb = server.GetDatabase(dbConnectionString.DatabaseName);
            return clientMongoDb;
        }
    }
}
